// Copyright 2014 Google Inc. All Rights Reserved.

#include <unistd.h>

void swab(__const void * __restrict s, void * __restrict d, ssize_t len) {
  const char* src = s;
  char* dst = d;

  while (len > 1) {
    dst[1] = *src++;
    dst[0] = *src++;
    dst += 2;
  }

  if (len == 1) {
    *dst = *src;
  }
}
